<?php 
namespace app\api\behavior;

use think\Request;
class CronRun{

	public function run(){
                //跨域访问的时候才会存在此字段
                $origin = isset($_SERVER['HTTP_ORIGIN']) ? $_SERVER['HTTP_ORIGIN'] : '';  
                   
                $allow_origin = array(  
                    'http://localhost:8080',  
                    'http://www.birongsen.com',
                    'http://birongsen.com',
                );  
                if(in_array($origin, $allow_origin)){  
                    header('Access-Control-Allow-Origin:'.$origin);  
                    header('Access-Control-Allow-Methods:GET, POST, PUT, DELETE, OPTIONS');  
                    header('Access-Control-Allow-Headers:Origin, X-Requested-With, Content-Type, Accept, authKey, sessionId');
                    header("Access-Control-Allow-Credentials: true");  
                }

        // $info = $_SERVER;
        // var_dump($info);
        // header('Access-Control-Allow-Origin: http://localhost:8080');
		// header('Access-Control-Allow-Origin: http://localhost:8080');
        // header('Access-Control-Allow-Origin: '.$_SERVER['SERVER_NAME']);
        // header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS');
        // header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, authKey, sessionId");
        // header("Access-Control-Allow-Credentials: true");
        // if(strtoupper( request()->method() ) == 'OPTIONS'){ 
        //     return Response::create()->send();
        // }
	}
}